<template>
    <elm-page-bb>
        <el-form ref="model" :model="model" size="small" label-width="100px">
            <elm-row>
                <el-form-item label="年月" prop="this_month" :rules="[{ required: true, message: '年月必须选择'}]">
                    <el-date-picker v-model="model.this_month" type="month" value-format="yyyy-MM" placeholder="选择年月" style="width: 100%"></el-date-picker>
                </el-form-item>
                <el-form-item label="总收入" prop="total_income" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.total_income">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
            </elm-row>
            <elm-row>
                <el-form-item label="净利润" prop="net_profit" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.net_profit">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
                <el-form-item label="毛利" prop="gross_profit" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.gross_profit">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
            </elm-row>
            <elm-row>
                <el-form-item label="营业成本" prop="bus_cost" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.bus_cost">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
                <el-form-item label="销售费用" prop="sell_cost" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.sell_cost">
                       <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
            </elm-row>
            <elm-row>
                <el-form-item label="管理费用" prop="manage_cost" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.manage_cost">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
                <el-form-item label="财务费用" prop="finance_cost" :rules="[{trigger: 'blur' ,validator: validateNumber}]">
                    <el-input v-model="model.finance_cost">
                        <template slot="append"><div style="width: 25px;text-align: center;">万元</div></template>
                    </el-input>
                </el-form-item>
            </elm-row>
            <el-form-item label="备注">
                <el-input type="textarea" v-model="model.remark" :rows="3"></el-input>
            </el-form-item>
        </el-form>
        <template #bottom>
            <el-button type="success" size="small" @click="submit">立即保存</el-button>
            <el-button size="small" @click="close">取消</el-button>
        </template>
    </elm-page-bb>
</template>

<script>
export default {
    extends: elmVueBase,
    data() {
        return {
            model: {
              id: elm.newGuid(),
              this_month: elm.parseTime(new Date(), '{y}-{m}'),
            },
        }
    },
    created() {
    },
    methods: {
        async submit() {
            await this.$refs["model"].validate();
            var res = await elm.post('/business/bms/month/tab/Upsert', this.model);
            if (res == true) {
                this.close();
                this.v('保存成功。');
                this.request.callVue.tablebinding();
            }
            else {
                this.error('保存失败，请稍后尝试。');
            }
        }
    }
}
</script>

<style scoped>
</style>